package com.example.demo01.controller;

import com.example.demo01.commen.Result;
import com.example.demo01.controller.request.LoginRequest;
import com.example.demo01.entity.User;
import com.example.demo01.mapper.UserMapper;
import com.example.demo01.service.impl.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@CrossOrigin
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    UserService userService;

    @GetMapping("/list")
    public List<User> listUser(){
     return userService.listUser();
    }

    @PostMapping("/login")
    public Result login(@RequestBody LoginRequest request){

        return Result.success(userService.login(request));
    }
}
